package dashboard.datasource;

import java.util.Collections;
import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import dashboard.dbentity.NetFlowCate;

public class NetFlowCateService  extends AbstractBaseService<NetFlowCate>{
	private static Log log = LogFactory.getLog(NetFlowCateService.class);
	
	/**
	 * 所有列
	 */
	private static final String COLUMN_ALL = "stat_date,platform,pagetype,chlname,disp_cate1_name,pv,visit,uv";

	/**
	 * 默认时间排序
	 */
	private static final String ORDERBY_DEFAULT = "stat_date";

	public List<NetFlowCate> search(String condition) {
		return search(null, condition, null);
	}

	public List<NetFlowCate> search(String condition, String orderby) {
		return search(null, condition, orderby);
	}

	public List<NetFlowCate> search(String col, String condition, String orderby) {
		if (StringUtils.isBlank(condition)) {
			return Collections.emptyList();
		}
		String column = col;
		if (StringUtils.isBlank(column)) {
			column = COLUMN_ALL;
		}

		String order = orderby;
		if (StringUtils.isBlank(order)) {
			order = ORDERBY_DEFAULT;
		}
		List<NetFlowCate> list = null;
		try {
			list = getListByConditon(column, condition, order);
		} catch (Exception e) {
			log.info(e);
		}

		if (list == null || list.isEmpty()) {
			return Collections.emptyList();
		}
		return list;
	}
}
